package mb.view;  

import java.awt.Container;
import java.awt.event.WindowListener;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import mb.model.Diagram;
import mb.config.Para;                   // +

public class AppFrame extends JFrame implements WindowListener {

  // {+

  private Para para = Para.getPara();

  private static String appTitle;

  {
    appTitle       = para.getT("appTitle");
  }
  // +}

  private AppMenu appMenu = new AppMenu(this);
  private AppToolBar appToolBar = new AppToolBar();
  private Diagram diagram = new Diagram(appToolBar);

  public AppFrame() {
    super();
    this.addWindowListener(this);
    this.setJMenuBar(this.appMenu);
    this.setTitle(appTitle);                       // &
    this.setSize(640, 480);                        // &
    Container cp = this.getContentPane();
    cp.add(appToolBar, "North");
    cp.add(new JScrollPane(diagram), "Center");
  }

  public Diagram getDiagram() {
    return diagram;
  }

  public void exit() {
    this.dispose();
    System.exit(0);
  }

  public void windowClosing(WindowEvent e) {
    this.exit();
  }

  public void windowOpened(WindowEvent e) {}
  public void windowClosed(WindowEvent e) {}
  public void windowIconified(WindowEvent e) {}
  public void windowDeiconified(WindowEvent e) {}
  public void windowActivated(WindowEvent e) {}
  public void windowDeactivated(WindowEvent e) {}

}
